/**
 * Copyright (C)  2011  chen wei hua.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 2.0
 * or any later version published by the Free Software Foundation;
 * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 * A copy of the license is included in the section entitled "GNU Free Documentation License".
 */
package com.javaeye.accounting.dto;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.javaeye.common.dto.DTO;
import com.javaeye.store.dto.MaterialsCategory;

public class MaterialsMonthInventoryCheck implements DTO {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2844773041688424970L;
	
	public static final int CHECK_STATUS_CREATE = 1;
	
	public static final int CHECK_STATUS_CHECKED = 2;
	
	public static final int CHECK_STATUS_ADJUST = 3;

	private String checkNo;
	
	private Date checkDate;
	
	private Set<MaterialsCategory> categorys;
	
	private int count;
	
	private double amount;
	
	private double realAmount;
	
	private double diffAmount;
	
	private int status;
	
	private String monthNo;
	
	private Set<MaterialsMonthInventoryCheckDetail> details;
	
	public MaterialsMonthInventoryCheck() {
		categorys = new HashSet<MaterialsCategory>();
		details = new HashSet<MaterialsMonthInventoryCheckDetail>();
	}
	
	public void addCategory(MaterialsCategory category) {
		categorys.add(category);
	}
	
	public void removeCategory(MaterialsCategory category) {
		categorys.remove(category);
	}
	
	public void addDetail(MaterialsMonthInventoryCheckDetail detail) {
		detail.setCheck(this);
		details.add(detail);
	}
	
	public void removeDetail(MaterialsMonthInventoryCheckDetail detail) {
		details.remove(detail);
		detail.setCheck(null);
	}
	
	public String getCategoryNames() {
		StringBuffer sb = new StringBuffer();
		for (MaterialsCategory c : categorys) {
			sb.append(c.getName());
			sb.append(",");
		}
		return sb.toString();
	}
	
	public String getStatusName() {
		switch (status){
		case CHECK_STATUS_CREATE:
			return "等待盘点";
		case CHECK_STATUS_CHECKED:
			return "等待调帐";
		case CHECK_STATUS_ADJUST:
			return "调帐结束";
		default :
			return "";
		}
	}

	public String getCheckNo() {
		return checkNo;
	}

	public void setCheckNo(String checkNo) {
		this.checkNo = checkNo;
	}

	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	public Set<MaterialsCategory> getCategorys() {
		return categorys;
	}

	public void setCategorys(Set<MaterialsCategory> categorys) {
		this.categorys = categorys;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public double getRealAmount() {
		return realAmount;
	}

	public void setRealAmount(double realAmount) {
		this.realAmount = realAmount;
	}

	public double getDiffAmount() {
		return diffAmount;
	}

	public void setDiffAmount(double diffAmount) {
		this.diffAmount = diffAmount;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Set<MaterialsMonthInventoryCheckDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<MaterialsMonthInventoryCheckDetail> details) {
		this.details = details;
	}

	public void setMonthNo(String monthNo) {
		this.monthNo = monthNo;
	}

	public String getMonthNo() {
		return monthNo;
	}

}
